#include <pwd.h>
#include <unistd.h>
#include <signal.h>
#include <iostream>
#include <stdlib.h>
#include <string.h>
using namespace std; 

static void my_alarm(int signo){
	struct passwd *rootptr; 
	cout << " in signal handler\n" ; 
	if((rootptr = getpwnam("root")) == NULL){
		cout << " getpwname(root) error \n"; 
		exit(-1); 
	}
	alarm(1);
}
int main(){ struct passwd *ptr; signal(SIGALRM,my_alarm);
	alarm(1); 
	for(;;){
		sleep(1);
		if((ptr = getpwnam("lifelong0811")) == NULL){
			cout << " getpwname(root) error \n"; 
			exit(-1); 
		}
		if(strcmp(ptr->pw_name,"ifelong0811") !=0 )
			cout << " value error" << ":" << 
			       ptr->pw_name << endl;	
	}
}
